package com.fangyu.lottery.repository;

import com.fangyu.lottery.model.Prize;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 奖品仓储接口
 * @author fangyu
 * @version v1.0.0
 * @since 2025/8/28 13:49
 */
public interface PrizeRepository extends JpaRepository<Prize, Long> {

    /**
     * 根据活动ID查询奖品列表
     * @param activityId 活动ID
     * @return 奖品列表
     */
    @Query("SELECT p FROM Prize p WHERE p.activityId = :activityId AND p.status = 1 ORDER BY p.probability DESC")
    List<Prize> findByActivityId(@Param("activityId") Long activityId);
}